package com.baifendian.common.task;

import com.baifendian.common.utils.DateUtils;
import com.baifendian.dao.entity.RcApiInterStat;
import com.baifendian.service.ExcApiTrackService;
import com.baifendian.service.RcApiInterStatService;
import java.util.Date;
import java.util.List;
import org.springframework.util.ObjectUtils;

/**
 * @author peng.guo on 2018/3/7.
 */
public class RcApiInterStatTask implements  Runnable{

  private RcApiInterStatService rcApiInterStatService;

  private String name;

  public RcApiInterStatTask(RcApiInterStatService rcApiInterStatService) {
    this.rcApiInterStatService = rcApiInterStatService;
  }

  public RcApiInterStatTask(RcApiInterStatService rcApiInterStatService,String name) {
    this.rcApiInterStatService = rcApiInterStatService;
    this.name = name;
  }

  @Override
  public void run() {
    Date date = DateUtils.stringToDate("02/22/2018");
    DateUtils.localDateTimeToDate(DateUtils.getCurrentTime());
    List<RcApiInterStat> rcApiInterStatList = rcApiInterStatService.getInterApiByGroup(date);
    if(ObjectUtils.isEmpty(rcApiInterStatList)){
      return;
    }
    rcApiInterStatService.delRcApiInterStat();
    rcApiInterStatService.saveRcApiInterStat(rcApiInterStatList);
    System.out.println("rcApiInterStatList" + rcApiInterStatList);
  }

}
